#!/usr/bin/python2.5
from google.appengine.api import mail

import logging

ADMIN_EMAIL = "Nikola Tepper <nikola.tepper@gmail.com>"

def ReportError(component, error_message):
    
    try:   
        message_body = "Error occured in kindly.cz. Affected component: %s\n%s" % (component, error_message)
        logging.debug("Sending error message: %s" % message_body)
        message = mail.EmailMessage(sender="nikola.tepper@gmail.com",
                                    subject="Error in kindly.cz")
        message.to = ADMIN_EMAIL
        message.body = message_body
        message.send()
    except  Exception, ex:
        logging.error("Failed to send error message. Error %s" % ex)


def SendInfo(infoType, details):
    
    try:   
        message_body = "%s from kindly.cz\n%s" % (infoType, details)
        logging.debug("Sending information message: %s" % message_body)
        message = mail.EmailMessage(sender="nikola.tepper@gmail.com",
                                    subject="%s from kindly.cz" % infoType)
        message.to = ADMIN_EMAIL
        message.body = message_body
        message.send()
    except  Exception, ex:
        logging.error("Failed to send information message. Error %s" % ex)
